﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Security;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.MsmqIntegration;
using System.Text;
using System.Threading.Tasks;

namespace WCFMsmqTest
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(WCFService)))
            {
                MsmqIntegrationBinding binding = new MsmqIntegrationBinding();
                binding.Security.Mode = MsmqIntegrationSecurityMode.None;
                binding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
                binding.Security.Transport.MsmqProtectionLevel = ProtectionLevel.None;

                EndpointAddress address = new EndpointAddress(@"net.msmq://10.1.115.248/private/TransactionalQueue_IUser");

                ContractDescription contract = ContractDescription.GetContract(typeof(IUser));
                ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, address);
                host.AddServiceEndpoint(endpoint);
                host.Opened += delegate(object sender, EventArgs e)
                {
                    Console.WriteLine("open");
                }
                    ;
                host.Open();

                Console.ReadKey();
            }

        }
    }
}
